package com.apes.auto.car.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * @ClassName Manufacturers
 * @Description TODO
 * @Author pengyb
 * @Date 2019/7/9 14:38
 * @Version 1.0
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = Manufacturers.CONST_TABLE_NAME,indexes = {
        @Index(columnList = "name")
})
public class Manufacturers extends Model {
    public static final String CONST_TABLE_NAME = "dc_manufacturers";
    @Id
    @Column(name = "id", length = 30)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "厂商")
    private String id;  //编码

    @Column(name = "name", nullable = false, length = 120)
    @Comment("名称")
    private String name; //名称


//    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY, mappedBy = "manufacturersList")
//    private List<CarBrand> carBrand = new ArrayList<>();

//    @OneToOne(cascade = CascadeType.REFRESH, orphanRemoval = true, mappedBy = "carBrandMessages")
//    private VehicleLabel vehicleLabel; //厂牌
}
